$(function(){
    var WapSiteUrl = '';

    // var goods_id = GetQueryString('goods_id');
    // var resource_tags = GetQueryString('resource_tags');
    // var dmid = GetQueryString('dmid');
    // var token = getcookie("token");
    // var mid = getcookie("mid");
    var goods_commonid;
    var goodsId;
    var curpage = 1,
        num = 10;
    var regu = /^[-]{0,1}[0-9]{1,}$/; //判断是否是整数;
    var count = 0; //当前商品总数 用来判断是否还要继续加载更多
    var type = 0;
    var wx_link; /*****添加微信分享用*******/
    var timeDown;



    commentList(type, 1, 'yes'); // 商品评论列表


    // 商品评论列表
    function commentList(type, curpage, appendtype) {
        $.ajax({
            url: WapSiteUrl + '/api/index.php?act=common_goods&op=get_goods_comments',
            type: 'get',
            dataType: 'json',
            data: {
                goods_id: goods_id,
                num: num,
                curpage: curpage,
                flag: 'wap',
                type: type
            },
            success: function (data) {

                if (data && data.error === '0') {
                    template.helper("daysBetween", daysBetween);
                    //评价头部
                    if (appendtype == 'yes') {
                        var html = template.render('details_comment_title_tpl', data.result);
                        $('#details_comment .details_comment-title').empty();
                        $('#details_comment .details_comment-title').html(html);

                        upRefresh(); //下拉加载
                    }
                    //当前评价标签显示
                    $('.details_comment_btn>button').eq(type).addClass('selected').siblings('button').removeClass('selected');
                    //评论为空 不显示当前标签样式   
                    if (data.result.comments == '') {
                        $('.details_comment_btn>button').removeClass('selected');
                    }

                    $('#details_comment .focus-color').text(data.result.good_percent + "%");
                    $('#details_comment .span-right').text(data.result.all_count + "人评价");


                    //评价内容
                    var html = template.render('details_comment_tpl', data.result);
                    if (appendtype == 'no') {
                        $('#details_comment .goods-assess>ul').append(html);
                    } else {
                        $('#details_comment .goods-assess>ul').empty();
                        $('#details_comment .goods-assess>ul').html(html);
                    }

                    $("#details_comment img").lazyload();


                    //评价分类 有图无图好评差评
                    $('.details_comment_btn>button').click(function (event) {
                        type = $(this).index();
                        console.log(type);
                        commentList(type, 1, 'yes');
                        $(this).addClass('selected').siblings('button').removeClass('selected');
                    });


                }
            }
        });
    }
    
  })




